# Makefile for fish pro

IDIR = include
FLAGS = -g -I$(IDIR)
CLIENTFLAGS = -lncurses -lpthread
OBJSERVER = server.o strlib.o genlib.o random.o exception.o listCDT.o sessADT.o sig.o sem.o shm.o log.o fifoADT.o msgADT.o shmADT.o tcpADT.o transADT.o myError.o
OBJCLIENT = client.o cl.o scanadt.o strlib.o genlib.o exception.o random.o sessADT.o sig.o sem.o shm.o fifoADT.o msgADT.o shmADT.o tcpADT.o transADT.o myErrorClient.o
SVNAME = chatserver
CLNAME = chats


# Rules for the main objective
all: client server
	@ echo Compiling...
	@ mkdir -p obj
	@ echo Moving all objects to obj directory...
	@ mv *.o ./obj
	@ echo Execute "make clean" to remove all objects


client:  $(OBJCLIENT)
	@ echo Compiling dependencies for the client...
	 $(CC) $(OBJCLIENT) $(CLIENTFLAGS) -o $(CLNAME)

server:  $(OBJSERVER)
	@ echo Compiling dependencies for the server...
	 $(CC) $(OBJSERVER) -o $(SVNAME)

# Rules for secondary objectives

client.o: ./client/client.c
	@ $(CC) -c $(FLAGS) $?

server.o: ./server/server.c
	@ $(CC) -c $(FLAGS) $?

listCDT.o: ./server/listCDT.c
	@ $(CC) -c $(FLAGS) $?

cl.o: ./client/cl.c
	@ $(CC) -c $(FLAGS) $?

scanadt.o: ./scanADT/scanadt.c
	@ $(CC) -c $(FLAGS) $?

strlib.o: ./scanADT/strlib.c
	@ $(CC) -c $(FLAGS) $?

genlib.o: ./scanADT/genlib.c
	@ $(CC) -c $(FLAGS) $?

exception.o: ./scanADT/exception.c
	@ $(CC) -c $(FLAGS) $?

random.o: ./scanADT/random.c
	@ $(CC) -c $(FLAGS) $?

sig.o: ./clsv/ipc/sig.c
	@ $(CC) -c $(FLAGS) $?

sessADT.o: ./superADT/sessADT.c
	@ $(CC) -c $(FLAGS) $?

sem.o: ./clsv/ipc/sem.c
	@ $(CC) -c $(FLAGS) $?

shm.o: ./clsv/ipc/shm.c
	@ $(CC) -c $(FLAGS) $?

myError.o: ./clsv/myError.c
	@ $(CC) -c $(FLAGS) $?

myErrorClient.o: ./client/myErrorClient.c
	@ $(CC) -c $(FLAGS) $?

log.o: ./clsv/log.c
	@ $(CC) -c $(FLAGS) $?

fifoADT.o: ./superADT/transport/ipc/fifoADT.c
	@ $(CC) -c $(FLAGS) $?

msgADT.o: ./superADT/transport/ipc/msgADT.c
	@ $(CC) -c $(FLAGS) $?

shmADT.o: ./superADT/transport/ipc/shmADT.c
	@ $(CC) -c $(FLAGS) $?

tcpADT.o: ./superADT/transport/ipc/tcpADT.c
	@ $(CC) -c $(FLAGS) $?

transADT.o: ./superADT/transport/transADT.c
	@ $(CC) -c $(FLAGS) $?


# Generate the binaries, and put everything where it belongs
clean: all
	@ echo Deleting objects...
	@ rm ./obj/*.o
